package org.rednebula.simple.model.service;

import org.rednebula.framework.core.IEnvironment;
import org.rednebula.framework.core.model.domain.IModel;
import org.rednebula.framework.core.model.domain.RootModel;
import org.rednebula.framework.core.model.form.BasicForm;
import org.rednebula.framework.core.model.form.IForm;
import org.rednebula.framework.core.service.AbstractHandlerService;
import org.rednebula.simple.model.model.PersonModel;
import org.springframework.stereotype.Component;

@Component
public class PersonHandlerService extends AbstractHandlerService {
	public IModel create(IEnvironment env, IForm form) {
		PersonModel person=getModel(PersonModel.class, env);
		RootModel rootModel=getRootModel();
		String ident=buildStringIdent(env, this.toLowerInitName(PersonModel.class));
		person.setIdent(ident);
		rootModel.push(person);
		((BasicForm)form).putInTemporary(PersonModel.class, person);
		return rootModel;
	}

	public IModel delete(IEnvironment env, IForm form) {
		return null;
	}

	public IModel find(IEnvironment env, IForm form) {
		return null;
	}

	public IModel modify(IEnvironment env, IForm form) {
		BasicForm f=(BasicForm)form;
		return f.findModelCache(env);
	}
}
